package queue;/*
 *@ 代阳敲的专属代码
 **/

public class MyCircularQueue {
    int [] array;
    public MyCircularQueue(int k) {
        array=new int[k];
    }
    int Front,Rear;
    int usSize=0;
    public boolean enQueue(int value) {
        if(isFull()) {
            return false;
        }
        array[Rear]=value;
        Rear=(Rear+1)%array.length;
        usSize++;
        return true;
    }

    public boolean deQueue() {
        if(isEmpty()) {
            return false;
        }
        int val=array[Front];
        Front=(Front+1)%array.length;
        return true;

    }

    public int Front() {
        if(isEmpty()) {
            return -1;
        }
        return array[Front];
    }

    public int Rear() {
        if(isEmpty()) {
            return -1;
        }
        return array[Rear];
    }

    public boolean isEmpty() {
        return  usSize==0;
    }

    public boolean isFull() {
       return usSize==array.length;
    }
}
